package main

import (
	"bytes"

	"gofw-im/lib/define"
	"gofw-im/lib/logger"
	"gofw-im/lib/proto"
)

var (
	userInfo map[string]string
)

func getRouterUserId(auth string) (userId string) {
	var key bytes.Buffer
	key.WriteString(define.REDIS_PREFIX)
	key.WriteString(auth)

	logger.Info.Printf("key %s", key.String())
	userId = RedisCli.HGet(key.String(), "UserId").Val()
	return
}

func getRouter(auth string) (router *proto.Router, err error) {
	userInfo, err = RedisCli.HGetAll(getKey(auth)).Result()
	if err != nil {
		return
	}
	router = &proto.Router{UserId: userInfo["UserId"], UserName: userInfo["UserName"]}
	return
}
